var t = require("../../../../@babel/runtime/helpers/objectSpread2"), e = getApp(), a = require("../../../../utils/themeSkin/skinBehavior");

Page({
    behaviors: [ a ],
    data: {
        userDataUrl: "plugin.customer-center.frontend.controllers.customer.get-customer",
        getConfig: {
            member_id: "",
            income_statistic_type: 0
        },
        memberInfo: {},
        income_statistic: [],
        tags: [],
        actions: [],
        navActive: 0,
        addTagText: "",
        showAddTagPop: !1,
        showAddSheet: !1,
        income_statistic_type: "0",
        tabList: [ "会员详情", "Ta的客户", "订单列表", "收入详情", "Ta的购物车", "优惠券", "商品收藏", "浏览足迹" ],
        showChild: !1,
        basicColor: ""
    },
    onLoad: function(t) {
        t.id && this.setData({
            "getConfig.member_id": t.id
        }), this.getUserData(), wx.setNavigationBarTitle({
            title: "用户信息"
        });
        try {
            var e = wx.getStorageSync("yz_basic_info").theme_color, a = wx.getStorageSync("langIndex");
            this.setData({
                language: a.en,
                basicColor: e
            });
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        var t = this.componentName();
        if ("orderList" != t && "browseRecord" != t) {
            var e = this.selectComponent("#".concat(t));
            e && (e.data.finished || e.loadMore());
        }
    },
    onShareAppMessage: function() {},
    componentName: function() {
        switch (this.data.navActive) {
          case 1:
            return "myCustomer";

          case 2:
            return "orderList";

          case 3:
            return "revenueDetails";

          case 4:
            return "myCart";

          case 5:
            return "goodsCoupon";

          case 6:
            return "myFavorite";

          case 7:
            return "browseRecord";
        }
    },
    getUserData: function() {
        var t = this, a = e.getNetAddresss(this.data.userDataUrl);
        e._postNetWork({
            url: a,
            showToastIn: !1,
            data: this.data.getConfig,
            success: function(e) {
                var a = e.data;
                1 == a.result ? (a.data.member && 0 == a.data.member.hasAuth && wx.showModal({
                    content: "暂无权限",
                    success: function(t) {
                        wx.navigateTo({
                            url: "/packageG/member_v2/member_v2"
                        });
                    }
                }), console.log(a, "ddddddddddddd"), t.setData({
                    showChild: !0,
                    tags: a.data.member.has_many_tag,
                    memberInfo: a.data.member,
                    income_statistic: a.data.statistics
                })) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    selectNav: function(t) {
        console.log(t), this.setData({
            navActive: t.detail.index
        });
    },
    selectTime: function(a) {
        var s = this;
        this.setData({
            income_statistic_type: a.detail.name,
            "getConfig.income_statistic_type": a.detail.name
        });
        var o = e.getNetAddresss(this.data.userDataUrl);
        e._postNetWork({
            url: o,
            data: t(t({}, this.data.getConfig), {}, {
                income_statistic_type: this.data.income_statistic_type
            }),
            success: function(t) {
                var e = t.data;
                1 == e.result ? s.setData({
                    income_statistic: e.data.statistics
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});